<?
		include("dbconn.inc");
		include("dbfuc.inc");
		include("session.inc");		
		$adminuser=$_SESSION["adminuser"];
		$adminid=$_SESSION["adminid"];		
		
	if(session_is_registered("adminuser") )
	{
	

		if(($adminuser!="") && (($adminid!="") || ($adminid!=0)))
		{

		$sql="";
		$cnt=0;$cslno=0;
		$cuser="";$cpass="";$status="";$cstatus="";$oldddate="";$ddate="";$oldmonth="";$dmonth="";$mon="";$bgcolor="";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: x-small;
	color: #FF0000;
}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: x-small; color: #FFFFFF; }
.style3 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: x-small;
}
.style5 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
}
.style6 {font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<? include "allheader.php"  ?>	
<br>
<br>
<table width="755" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#659931">
  <tr>
    <td colspan="7" bgcolor="#659931" class="style2"><div align="center">Coupon Details </div></td>
  </tr>
  <tr bgcolor="#BEE09C">
    <td width="41" class="style5"><div align="center"><span class="style5">SL No </span></div></td>
    <td width="98" class="style5"><div align="center">Coupon <br>
    Serial No </div></td>
    <td width="167" class="style5"><div align="center">Coupon User </div></td>
    <td width="162" class="style5"><div align="center">Coupon Password </div></td>
    <td width="139" class="style5"><div align="center">Date of Allotment </div></td>
    <td width="110" class="style5"><div align="center">Status</div></td>
  </tr>
<?
		$sql="select N_SLNO,C_COUPON_NAME,C_COUPON_PASSWORD,C_STATUS,D_DATE from mlm_coupon_details WHERE n_id!=0 ORDER BY D_DATE";
			$result=mysql_query($sql);
			$rownum=mysql_num_rows($result);
			while($rownum >0)
			{
				$cnt=$cnt+1;
				$rownum=$rownum-1;
				$slno=mysql_result($result,$rownum,"N_SLNO");
				$couponuser=mysql_result($result,$rownum,"C_COUPON_NAME");			
				$couponpassword=mysql_result($result,$rownum,"C_COUPON_PASSWORD");
				$status=mysql_result($result,$rownum,"C_STATUS");
				$ddate=mysql_result($result,$rownum,"D_DATE");

		if($status=="N")
			$cstatus="BALANCE";
		else if($status=="Y")
			$cstatus="<a href='issued_couponuser_details.php?ctuser=$couponuser'>USED</a>";
?>
<?
/*			
		dmonth=ddate.substring(3,5);
		if(dmonth.equals("01"))  
			mon="January";
		if(dmonth.equals("02"))  
			mon="February";
		if(dmonth.equals("03")) 
			mon="March";
		if(dmonth.equals("04"))  
			mon="April";	
		if(dmonth.equals("05"))
			mon="May";	
		if(dmonth.equals("06"))
			mon="June";	
		if(dmonth.equals("07")) 
			mon="July";	
		if(dmonth.equals("08")) 
			mon="August";	
		if(dmonth.equals("09"))
			mon="September";	
		if(dmonth.equals("10"))
			mon="October";	
		if(dmonth.equals("11"))
			mon="November";	
		if(dmonth.equals("12"))
			mon="December";	
		
		if(!oldmonth.equals(dmonth))
		{
%>
			<tr bgcolor="#FFFFDF">
			  <td colspan="7" class="style1"><%=mon%></td>
			</tr>
<%			
		}
		oldmonth=dmonth;			
		if(!oldddate.equals(ddate))
		{
%>
			<tr bgcolor="#FFFFDF">
			  <td colspan="7" bgcolor="#CCCCCC" class="style6"><%=ddate%></td>
			</tr>
<%			
		cnt=1;
		}
		oldddate=ddate;					
%>
*/	
?>  <tr bgcolor="#EAF4DF">
		<td class="style3"><div align="center"><? echo $cnt ?></div></td>
		<td class="style3"><div align="center"><? echo $slno ?></div></td>
		<td class="style3"><div align="center"><? echo $couponuser ?></div></td>
		<td class="style3"><div align="center"><? echo $couponpassword ?></div></td>
		<td class="style3"><div align="center"><? echo $ddate ?></div></td>
	    <td class="style3"><div align="center"><? echo $cstatus ?></div></td>
	  </tr>
<?
	}

	if($cnt==0)
	{
?>
		  <tr>
			<td colspan="7" bgcolor="#EAF4DF"><div align="center" class="style1">No Records Found </div></td>
		  </tr>
<?
	}
?>
</table>
</body>
</html>
<?
		}	
    }
	else
	{
		$errormsg="*Your session is expeired please login again";
		header("location: index.php?error=$errormsg");
	}
?>	
